<?php
class Model_AdminAcl extends Zend_Acl{
	public function __construct(){
		$this->addRole(new Zend_Acl_Role('guests'));
		$this->addRole(new Zend_Acl_Role('2'),'guests');
		$this->addRole(new Zend_Acl_Role('1'),'2');
		
		$this->add(new Zend_Acl_Resource("admin"))
				->add(new Zend_Acl_Resource("admin:index"),"admin")
				->add(new Zend_Acl_Resource("admin:admin"),"admin")
				->add(new Zend_Acl_Resource("admin:error"),"admin")
				->add(new Zend_Acl_Resource("admin:contact"),"admin")
				->add(new Zend_Acl_Resource("admin:menu"),"admin")
				->add(new Zend_Acl_Resource("admin:object"),"admin")
				->add(new Zend_Acl_Resource("admin:objectlibphoto"),"admin")
				->add(new Zend_Acl_Resource("admin:objectphotoprofile"),"admin")
				->add(new Zend_Acl_Resource("admin:page"),"admin");
		$this->add(new Zend_Acl_Resource("default"))
			->add(new Zend_Acl_Resource("default:index"),"default")
			->add(new Zend_Acl_Resource("default:architect"),"default")
			->add(new Zend_Acl_Resource("default:product"),"default")
			->add(new Zend_Acl_Resource("default:promotion"),"default");
		// phân quyền cho 3 cấp
		$this->allow("guests","default:index","index");
		$this->allow("guests","default:architect",array("index","detail","showlibphoto","showlibphoto2","showlibphoto3","popup"));
		$this->allow("guests","default:product",array("index","detail","showlibphoto","popup","sholibphoto2"));
		$this->allow("guests","default:promotion",array("index"));
		$this->allow("guests","admin:index","login");
		$this->allow("guests","admin:error","error");
		$this->deny("2","admin:index","login");
		$this->allow("2","admin:index","logout");
		$this->allow("2","admin:index","index");
		$this->allow("2","admin:admin","index");
		$this->allow("1","admin:admin",array("edit","del","active"));
		$this->allow("2","admin:contact","index");
		$this->allow("2","admin:menu","index");
		$this->allow("2","admin:object",array("product","architect","promotion"));
		$this->allow("2","admin:objectlibphoto","index");
		$this->allow("2","admin:objectphotoprofile","index");
		$this->allow("2","admin:page","index");

		//phân quyền cho cấp độ quản trị viên cao cấp
		$this->allow("1","admin:contact",array("edit","del","active"));
		$this->allow("1","admin:menu",array("edit","del","active"));
		$this->allow("1","admin:object",array("editp","edita","del","active","delp"));
		$this->allow("1","admin:objectlibphoto",array("edit","del","active"));
		$this->allow("1","admin:objectphotoprofile",array("del1","del2","active","activelib","libphoto","editci","editlibp"));
		$this->allow("1","admin:page",array("edit","del","active"));
	}
}